package com.bytech.common.biz.entity.timeline;

import java.io.Serializable;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

import com.bytech.common.biz.entity.article.ArticleDto;
import com.bytech.common.biz.entity.articleTag.ArticleTag;
import lombok.Data;

/**
 * @Author Zhao
 * @Create 2021/12/24 14:27
 */
@Data
public class TimeLineItem implements Serializable {
    private static final long serialVersionUID = 5661249865023788283L;

    private String articleId;
    private String title;
    private String content;
    private Integer year;
    private Integer month;
    private Date time;
    private List<ArticleTag> tagList; // 文章标签列表
    private Integer viewCount; // 文章浏览量
    private Integer thumbCount; // 文章点赞数

    public TimeLineItem() {

    }

    public TimeLineItem(ArticleDto articleDto) {
        this.articleId = articleDto.getId();
        this.title = articleDto.getTitle();
        this.content = articleDto.getSummary();
        Calendar c = Calendar.getInstance();
        c.setTime(articleDto.getCreateTime());
        this.year = c.get(Calendar.YEAR);
        this.month = c.get(Calendar.MONTH) + 1; // 月份从 0 开始
        this.time = articleDto.getCreateTime();
        this.tagList = articleDto.getTags();
        this.viewCount = articleDto.getViewCount();
        this.thumbCount = articleDto.getThumbCount();
    }
}
